<!--#begin select -->
<form method="post" action="{ babPhpSelf }">
<!--#in _getnexthidden -->
<input type="hidden" name="{ name }" value="{ value }" />
<!--#endin _getnexthidden -->

	<table width="90%" border="0" cellspacing="0" cellpadding="2" align="center">
	<tr> 
		<td class="BabLoginCadreBackground" align="center"> 
		<table class="BabLoginMenuBackground" width="100%" border="0" cellspacing="0" cellpadding="10">
		
		
		<tr align="center"> 
			<td width="40%">
				<p><label for="BAB_selectusers_searchtext">{ t_search }</label></p>
				<input type="text" id="BAB_selectusers_searchtext" name="searchtext" value="{ searchtext }" /> 
				<input type="submit" name="act[search]" value="{ t_searchsubmit }" />
			</td>

			<td>&nbsp;</td>

			<td width="40%">
				<br />
				<br />
				<h5>{ t_selected_users }</h5>
			</td>
		</tr>
		
		
		<tr align="center"> 
			<td valign="top">
				<select name="searchresult[]" multiple="multiple" size="10" style="width:100%">
					<!--#in _getnextsearchresult -->
					<option value="{ id_user }" onclick="searchresult_select_click('{ entry_url }', this)">{ username }</option>
					<!--#endin _getnextsearchresult -->
				</select>
				<p>
				{ t_view_directory_entry_for } <a id="bab_searchresult_entrylink" href="" onclick="bab_popup(this.href);return false;"></a>
				</p>
			</td>

			<td valign="middle">
				<p><input type="submit" name="act[grab]" value="{ t_grab_users }" /></p>
				<p><input type="submit" name="act[drop]" value="{ t_drop_users }" /></p>
			</td>

			<td valign="top">
				<select name="selectedusers[]" multiple="multiple" size="10" style="width:100%">
					<!--#in _getnextselecteduser -->
					<option value="{ id_user }">{ username }</option>
					<!--#endin _getnextselecteduser -->
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="3" align="center">
				<br />
				<input name="act[record]" type="submit" value="{ t_record }" />
				<br />
				<br />
			</td>
		</tr>
		</table>
		</td>
	</tr>
	</table>
</form>

<script>

function searchresult_select_click(entry_url, obj) {
	
	var a = document.getElementById('bab_searchresult_entrylink');
	
	if ('' != entry_url) {
	
		a.parentNode.style.visibility = 'visible';
	
		if (a.lastChild) {
			a.removeChild(a.lastChild);
		}
		a.appendChild(document.createTextNode(obj.innerHTML));
		a.href = entry_url;
		
	} else {
		a.parentNode.style.visibility = 'hidden';
		
	}
}


searchresult_select_click('', false);

</script>
<!--#end select -->




<!--#begin selectCalendarUsers -->
<script type="text/javascript">
//<![CDATA[

function bab_moveSelection(sFromId, sToId)
{
	var oFromCtrl		= document.getElementById(sFromId);
	var oToCtrl			= document.getElementById(sToId);
	
	if(null !== oFromCtrl && null !== oToCtrl )
	{
		var aCtrlToMove = new Array();
		
		var iLength = oFromCtrl.length;
		for(var iIndex = 0; iIndex < iLength; ++iIndex)
		{
			if(true === oFromCtrl.options[iIndex].selected)
			{
				aCtrlToMove[aCtrlToMove.length] = oFromCtrl.options[iIndex];
			}
		}
		
		var iLength = aCtrlToMove.length;
		if(iLength > 0)
		{
			var oNode = null;
			
			for(iIndex = 0; iIndex < iLength; ++iIndex)
			{
				oToCtrl.appendChild(aCtrlToMove[iIndex]);
			}
		}
		
		setTimeout(function(){
			bab_selectOption('oAccessView', 'All'); 
			bab_selectOption('oAccessUpdate', 'All'); 
			bab_selectOption('oAccessFull', 'All'); 
			bab_selectOption('oAccessSharedUpdate', 'All'); 
			bab_selectOption('oAccessSharedFull', 'All');
			
			var oInput = new Element('input', { 'type': 'hidden', 'name': 'act[sRefresh]' });
        	$('oCalAccessForm').insert(oInput).submit();
			}, 0); 
	}
}


document.observe('dom:loaded', function(){
	var oAccessViewMenuItems = [
	  {
	    name: '{ sMoveTo } { sAccessUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessView', 'oAccessUpdate');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessFull }',
	    callback: function() {
	      bab_moveSelection('oAccessView', 'oAccessFull');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessSharedUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessView', 'oAccessSharedUpdate');
	    }
	  }
	]
	
	new Proto.Menu({
	  selector: '#oAccessView', // context menu will be shown when element with id of "contextArea" is clicked
	  className: 'menu desktop', // this is a class which will be attached to menu container (used for css styling)
	  menuItems: oAccessViewMenuItems // array of menu items
	})
	
	
	var oAccessUpdateMenuItems = [
	  {
	    name: '{ sMoveTo } { sAccessView }',
	    callback: function() {
	      bab_moveSelection('oAccessUpdate', 'oAccessView');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessFull }',
	    callback: function() {
	      bab_moveSelection('oAccessUpdate', 'oAccessFull');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessSharedUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessUpdate', 'oAccessSharedUpdate');
	    }
	  }
	]

	new Proto.Menu({
	  selector: '#oAccessUpdate', // context menu will be shown when element with id of "contextArea" is clicked
	  className: 'menu desktop', // this is a class which will be attached to menu container (used for css styling)
	  menuItems: oAccessUpdateMenuItems // array of menu items
	})
	
	
	var oAccessFullMenuItems = [
	  {
	    name: '{ sMoveTo } { sAccessView }',
	    callback: function() {
	      bab_moveSelection('oAccessFull', 'oAccessView');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessFull', 'oAccessUpdate');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessSharedUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessFull', 'oAccessSharedUpdate');
	    }
	  }
	]
	new Proto.Menu({
	  selector: '#oAccessFull', // context menu will be shown when element with id of "contextArea" is clicked
	  className: 'menu desktop', // this is a class which will be attached to menu container (used for css styling)
	  menuItems: oAccessFullMenuItems // array of menu items
	})
	
	
	var oAccessSharedUpdateMenuItems = [
	  {
	    name: '{ sMoveTo } { sAccessView }',
	    callback: function() {
	      bab_moveSelection('oAccessSharedUpdate', 'oAccessView');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessSharedUpdate', 'oAccessUpdate');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessFull }',
	    callback: function() {
	      bab_moveSelection('oAccessSharedUpdate', 'oAccessFull');
	    }
	  }
	]
	
	new Proto.Menu({
	  selector: '#oAccessSharedUpdate', // context menu will be shown when element with id of "contextArea" is clicked
	  className: 'menu desktop', // this is a class which will be attached to menu container (used for css styling)
	  menuItems: oAccessSharedUpdateMenuItems // array of menu items
	})
	
	
	var oAccessSharedFullMenuItems = [
	  {
	    name: '{ sMoveTo } { sAccessView }',
	    callback: function() {
	      bab_moveSelection('oAccessSharedFull', 'oAccessView');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessSharedFull', 'oAccessUpdate');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessFull }',
	    callback: function() {
	      bab_moveSelection('oAccessSharedFull', 'oAccessFull');
	    }
	  },{
	    name: '{ sMoveTo } { sAccessSharedUpdate }',
	    callback: function() {
	      bab_moveSelection('oAccessSharedFull', 'oAccessSharedUpdate');
	    }
	  }
	]
	
	new Proto.Menu({
	  selector: '#oAccessSharedFull', // context menu will be shown when element with id of "contextArea" is clicked
	  className: 'menu desktop', // this is a class which will be attached to menu container (used for css styling)
	  menuItems: oAccessSharedFullMenuItems // array of menu items
	})
})

bab_initFunctions.push(function() { document.onmousemove = bab_tooltipPosition; });

//]]>
</script>

<form method="post" id="oCalAccessForm" action="{ babPhpSelf }">
	<!--#in _getnexthidden -->
	<input type="hidden" name="{ name }" value="{ value }" />
	<!--#endin _getnexthidden -->

	<table width="90%" border="0" cellspacing="0" cellpadding="2" align="center">
		<tr> 
			<td class="BabLoginCadreBackground" align="center"> 
				<table class="BabLoginMenuBackground" width="100%" border="0" cellspacing="0" cellpadding="10">
					<tr align="center"> 
						<td width="40%">
							<p><label for="BAB_selectusers_searchtext">{ t_search }</label></p>
							<img src="{ babInstallPath }skins/ovidentia/images/Puces/help.png" alt="" onmouseout="bab_showOnMouse('oSearchInfo', 0)" onmouseover="bab_showOnMouse('oSearchInfo', 1)" />&nbsp;&nbsp;<input type="text" id="BAB_selectusers_searchtext" name="searchtext" value="{ searchtext }" /> 
							<input type="submit" id="oSearch" name="act[search]" value="{ t_searchsubmit }" />
							<div id="oSearchInfo">{ sWildcard }</div>
						</td>
						<td>&nbsp;</td>
						<td width="40%">&nbsp;</td>
					</tr>
				
					<tr> 
						<td valign="top" rowspan="5">
							{ sSelect }:&nbsp;<a href="#" onclick="bab_selectAllOption('oSearchResult'); return false;">{ sAll }</a>,&nbsp;<a href="#" onclick="bab_deselectAllOption('oSearchResult'); return false;">{ sNone }</a>
							<br />
							<select id="oSearchResult" name="aSearchResult[]" multiple="multiple" size="35" style="width:100%">
								<!--#in _getnextsearchresult -->
								<option value="{ id_user }" onclick="bab_searchResultSelectClick('{ entry_url }', this)">{ username }</option>
								<!--#endin _getnextsearchresult -->
							</select>
							<p>
							{ t_view_directory_entry_for } <a id="bab_searchResultEntryLink" href="" onclick="bab_popup(this.href);return false;"></a>
							</p>
						</td>
			
						<td valign="middle" align="center">
							<p><input class="bab_grabUser" type="submit" name="act[sGrabAccessView]" value="{ sGrapCaption }" /></p>
							<p><input class="bab_dropUser" type="submit" name="act[sDropAccessView]" value="{ sDropCaption }" /></p>
						</td>
			
						<td valign="top">
  							<h5>{ sAccessView }</h5>
							{ sSelect }:&nbsp;<a href="#" onclick="bab_selectAllOption('oAccessView'); return false;">{ sAll }</a>,&nbsp;<a href="#" onclick="bab_deselectAllOption('oAccessView'); return false;">{ sNone }</a>
							<br />
							<select id="oAccessView" name="aAccessView[]" multiple="multiple" size="3" style="width:100%">
								<!--#in _getNextAccessViewItem -->
								<option value="{ id_user }">{ username }</option>
								<!--#endin _getNextAccessViewItem -->
							</select>
						</td>
					</tr>
			
					<tr> 
						<td valign="middle" align="center">
							<p><input class="bab_grabUser" type="submit" name="act[sGrabAccessUpdate]" value="{ sGrapCaption }" /></p>
							<p><input class="bab_dropUser" type="submit" name="act[sDropAccessUpdate]" value="{ sDropCaption }" /></p>
						</td>
						<td valign="top">
							<h5>{ sAccessUpdate }</h5>
							<div>{ sAccessUpdateHelp }</div>
							{ sSelect }:&nbsp;<a href="#" onclick="bab_selectAllOption('oAccessUpdate'); return false;">{ sAll }</a>,&nbsp;<a href="#" onclick="bab_deselectAllOption('oAccessUpdate'); return false;">{ sNone }</a>
							<br />
							<select id="oAccessUpdate" name="aAccessUpdate[]" multiple="multiple" size="3" style="width:100%">
								<!--#in _getNextAccessUpdateItem -->
								<option value="{ id_user }">{ username }</option>
								<!--#endin _getNextAccessUpdateItem -->
							</select>
						</td>
					</tr>
		
					<tr> 
						<td valign="middle" align="center">
							<p><input class="bab_grabUser" type="submit" name="act[sGrabAccessFull]" value="{ sGrapCaption }" /></p>
							<p><input class="bab_dropUser" type="submit" name="act[sDropAccessFull]" value="{ sDropCaption }" /></p>
						</td>
						<td valign="top">
							<h5>{ sAccessFull }</h5>
							<div>{ sAccessFullHelp }</div>
							{ sSelect }:&nbsp;<a href="#" onclick="bab_selectAllOption('oAccessFull'); return false;">{ sAll }</a>,&nbsp;<a href="#" onclick="bab_deselectAllOption('oAccessFull'); return false;">{ sNone }</a>
							<br />
							<select id="oAccessFull" name="aAccessFull[]" multiple="multiple" size="3" style="width:100%">
								<!--#in _getNextAccessFullItem -->
								<option value="{ id_user }">{ username }</option>
								<!--#endin _getNextAccessFullItem -->
							</select>
						</td>
					</tr>
					
					<tr> 
						<td valign="middle" align="center">
							<p><input class="bab_grabUser" type="submit" name="act[sGrabAccessSharedUpdate]" value="{ sGrapCaption }" /></p>
							<p><input class="bab_dropUser" type="submit" name="act[sDropAccessSharedUpdate]" value="{ sDropCaption }" /></p>
						</td>
						<td valign="top">
							<h5>{ sAccessSharedUpdate }</h5>
							<div>{ sAccessSharedUpdateHelp }</div>
							{ sSelect }:&nbsp;<a href="#" onclick="bab_selectAllOption('oAccessSharedUpdate'); return false;">{ sAll }</a>,&nbsp;<a href="#" onclick="bab_deselectAllOption('oAccessSharedUpdate'); return false;">{ sNone }</a>
							<br />
							<select id="oAccessSharedUpdate" name="aAccessSharedUpdate[]" multiple="multiple" size="3" style="width:100%">
								<!--#in _getNextAccessSharedUpdateItem -->
								<option value="{ id_user }">{ username }</option>
								<!--#endin _getNextAccessSharedUpdateItem -->
							</select>
						</td>
					</tr>
					
					
		
					<tr>
						<td colspan="3" align="center">
							<br />
							<input id="oSave" name="act[record]" type="submit" value="{ t_record }" />
							<br />
							<br />
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>

<script type="text/javascript">
//<![CDATA[
function bab_searchResultSelectClick(entry_url, obj)
{
	var a = document.getElementById('bab_searchResultEntryLink');
	
	if('' != entry_url) 
	{
		a.parentNode.style.visibility = 'visible';
	
		if(a.lastChild) 
		{
			a.removeChild(a.lastChild);
		}
		a.appendChild(document.createTextNode(obj.innerHTML));
		a.href = entry_url;
		
	} 
	else
	{
		a.parentNode.style.visibility = 'hidden';
	}
}

function bab_selectOption(sControlId, sAction)
{
	var bSelect;
	if('All' === sAction)
	{
		bSelect = true;
	}
	else if('None' === sAction)
	{
		bSelect = false;
	}
	else
	{
		return;
	}

	var oControl = document.getElementById(sControlId);
	if(null !== oControl)
	{
		var iLength = oControl.length;
		
//		alert(sControlId + ' iNbChild ==> ' + iLength);
		
		for(var iIndex = 0; iIndex < iLength; ++iIndex)
		{
			oControl.options[iIndex].selected = bSelect;
		}
	}
}


function bab_selectAllOption(sControlId)
{
	bab_selectOption(sControlId, 'All');
}

function bab_deselectAllOption(sControlId)
{
	bab_selectOption(sControlId, 'None');
}

bab_searchResultSelectClick('', false);
//]]>
</script>
<!--#end selectCalendarUsers -->
